<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.ejoysoft.wlanyz.business.Graph,java.text.SimpleDateFormat,com.ejoysoft.wlanyz.business.SignalClassTwoAc,com.ejoysoft.wlanyz.business.SignalClassOneAc,com.ejoysoft.wlanyz.business.SignalCountry,com.ejoysoft.wlanyz.business.Signal,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException,java.sql.*,java.util.*,java.util.Date"  %>
<%@page import="com.ejoysoft.common.Format"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
      if(!globa.userSession.hasRight("20015"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
 try{     
      String path = request.getContextPath();
      String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	 //初始化
    SignalClassTwoAc  SignalClassTwoAc0=null;
    SignalClassTwoAc obj=new SignalClassTwoAc(globa);
    request.setCharacterEncoding("UTF-8");
    
    //查询条件
    String  strCity = ParamUtil.getString(request,"strCity","").trim();//获取城市名
    String  strCountry = ParamUtil.getString(request,"strCountry","").trim();//获取区县
    String strClassOneAC = ParamUtil.getString(request,"ClassoneAc","").trim();//获取一级热点
    String  strClassTwoAC=ParamUtil.getString(request,"strClassTwoAC","").trim();//获取二级热点名
    String timedegree = ParamUtil.getString(request,"timedegree","").trim();//获取时间粒度
    String strStartTime = ParamUtil.getString (request,"strStartTime","").trim();//获取开始时间
    String strEndTime = ParamUtil.getString(request,"strEndTime","").trim();//获取结束时间
     int flag=Integer.parseInt(ParamUtil.getString(request,"Flag","0"));
      if(strStartTime !=null && !strStartTime.equals("")){
    String[] ST = strStartTime.trim().split(" ");
    String[] ST2 = ST[0].split("-");
    if(ST2[0].length()==4){
    strStartTime = ST2[2] + "-"+ ST2[1] + "-" + ST2[0].substring(2)+" "+ST[1];
    }
     }
     if(strEndTime !=null && !strEndTime.equals("")){
    String[] ET = strEndTime.split(" ");
     String[] ET2 = ET[0].split("-");
     if(ET2[0].length()==4){
    strEndTime = ET2[2] + "-"+ ET2[1] + "-" + ET2[0].substring(2)+" "+ET[1];
    }
    }
     
	strClassOneAC=Format.forbidSpecString(strClassOneAC);    
	strClassTwoAC=Format.forbidSpecString(strClassTwoAC);      
    ArrayList<Double>  beans = new ArrayList<Double>();
    if(flag==1){
    Signal  Signal0=null;
    Signal obj1=new Signal(globa);
    beans = obj1.getAPNRsn(strCity,timedegree,strStartTime,strEndTime);
    }
    if(flag==2){
    SignalCountry  SignalCountry0=null;
    SignalCountry obj2=new SignalCountry(globa);
    beans = obj2.getAPNRsn(strCity,strCountry,timedegree,strStartTime,strEndTime);
   
    }
    if(flag==3){
    SignalClassOneAc  SignalClassOneAc0=null;
    SignalClassOneAc obj3=new SignalClassOneAc(globa);
    beans = obj3.getAPNRsn(strCity,strCountry,strClassOneAC,timedegree,strStartTime,strEndTime);
   
   }
   if(flag==4){
    SignalClassTwoAc  SignalClassTwoAc00=null;
    SignalClassTwoAc obj4=new SignalClassTwoAc(globa);
    beans = obj.getAPNRsn(strCity,strCountry,strClassOneAC,strClassTwoAC,timedegree,strStartTime,strEndTime);
    }
    Graph g = new Graph();
   %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="../common/css/css.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><%=strCity %>场强分布图</title>
</head>
<body bgcolor="#F5FFFA" >

<% 
    double min = beans.get(0);
    double max = beans.get(0);
    for(int i=1;i<beans.size();i++)
    {
    if (beans.get(i)<min) min = beans.get(i);
    if (beans.get(i)>max) max = beans.get(i);
    }
    //System.out.println("AP个数:"+beans.size());

  java.util.List<String> data = new java.util.ArrayList<String>();//统计各个范围内AP个数
  java.util.List<String> labels = new java.util.ArrayList<String>();//设置x轴
  //构造x轴 和函数值
  for(int x = (int)(min);x< (int)(max+1);x++)
  {
    int count = 0;
    for(int j=0; j<beans.size(); j++)
    {
      if(beans.get(j)>=x&&beans.get(j)<x+1)count++;
    }

    data.add(String.valueOf(count));
    labels.add(Integer.toString(x)+"~"+Integer.toString(x+1));
  }
  //计算y轴最大值
  int max0=Integer.parseInt(data.get(0));
  for(int k=0; k<data.size(); k++){
    if(max0<Integer.parseInt(data.get(k)))
    max0=Integer.parseInt(data.get(k));
  }
  g.set_width(599);
  g.set_height(290);//设置图形区域的大小
  g.set_bg_colour("#F5FFFA");//背景颜色
  g.set_inner_background("#F5FFFA");//坐标轴内背景色
  g.set_data( data );
  g.set_y_min(0);//y轴最小值为0
  while((max0%5)!=0)max0++;
  int x =labels.size();
  while(x%8!=0)x++;
  g.set_y_max(max0);
  g.set_x_labels(labels);
  g.set_x_axis_steps( 2 );//坐标内间隔线的距离
  g.y_label_steps(5);//将y轴分成10段
  g.set_x_legend("场强大小(dBm)",12,"#ff00ff");
  g.set_x_label_style("10","#000000",0,x/8,"#EAEAEA");//x轴标注字体大小为13  标注文字颜色是银灰色  水平反方向  线条间隔为1  x轴间隔线条颜色是ffffff

  g.x_axis_colour("#EAEAEA","#EAEAEA");
  g.y_axis_colour("#EAEAEA","#EAEAEA");

// label every 20 (0,20,40,60)
%>
<%= g.render("js")  %>
</body>

</html>
<%}catch(Exception e){e.printStackTrace();} %>
<%@ include file="../include/jsp/footer.jsp"%>